package com.ruoyi.xp.order.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xp.order.domain.OrderIncome;
import com.ruoyi.xp.order.service.IOrderIncomeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 虾皮订单收入信息Controller
 * 
 * @author chdx
 * @date 2022-12-04
 */
@Controller
@RequestMapping("/order/OrderIncome")
public class OrderIncomeController extends BaseController
{
    private String prefix = "order/OrderIncome";

    @Autowired
    private IOrderIncomeService orderIncomeService;

    @RequiresPermissions("order:OrderIncome:view")
    @GetMapping()
    public String OrderIncome()
    {
        return prefix + "/OrderIncome";
    }

    /**
     * 查询虾皮订单收入信息列表
     */
    @RequiresPermissions("order:OrderIncome:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OrderIncome orderIncome)
    {
        startPage();
        List<OrderIncome> list = orderIncomeService.selectOrderIncomeList(orderIncome);
        return getDataTable(list);
    }

    /**
     * 导出虾皮订单收入信息列表
     */
    @RequiresPermissions("order:OrderIncome:export")
    @Log(title = "虾皮订单收入信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OrderIncome orderIncome)
    {
        List<OrderIncome> list = orderIncomeService.selectOrderIncomeList(orderIncome);
        ExcelUtil<OrderIncome> util = new ExcelUtil<OrderIncome>(OrderIncome.class);
        return util.exportExcel(list, "虾皮订单收入信息数据");
    }

    /**
     * 新增虾皮订单收入信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存虾皮订单收入信息
     */
    @RequiresPermissions("order:OrderIncome:add")
    @Log(title = "虾皮订单收入信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OrderIncome orderIncome)
    {
        return toAjax(orderIncomeService.insertOrderIncome(orderIncome));
    }

    /**
     * 修改虾皮订单收入信息
     */
    @RequiresPermissions("order:OrderIncome:edit")
    @GetMapping("/edit/{orderIncomeId}")
    public String edit(@PathVariable("orderIncomeId") Long orderIncomeId, ModelMap mmap)
    {
        OrderIncome orderIncome = orderIncomeService.selectOrderIncomeByOrderIncomeId(orderIncomeId);
        mmap.put("orderIncome", orderIncome);
        return prefix + "/edit";
    }

    /**
     * 修改保存虾皮订单收入信息
     */
    @RequiresPermissions("order:OrderIncome:edit")
    @Log(title = "虾皮订单收入信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OrderIncome orderIncome)
    {
        return toAjax(orderIncomeService.updateOrderIncome(orderIncome));
    }

    /**
     * 删除虾皮订单收入信息
     */
    @RequiresPermissions("order:OrderIncome:remove")
    @Log(title = "虾皮订单收入信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(orderIncomeService.deleteOrderIncomeByOrderIncomeIds(ids));
    }
}
